/**
 * Copyright (c) 2011 ~ 2014 Deepin, Inc.
 *               2013 ~ 2014 jouyouyun
 *
 * Author:      jouyouyun <jouyouwen717@gmail.com>
 * Maintainer:  jouyouyun <jouyouwen717@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 **/

package main

import (
        "dbus/com/deepin/api/search"
        "fmt"
)

var pyObj *search.Search

func testSearch() {
        testMap := make(map[string]string)
        testMap["Launcher"] = "Launcher"
        testMap["Test"] = "Test"
        testMap["terminal"] = "Terminator"
        md5, err1 := pyObj.NewTrieWithString(testMap, "test1")
        if err1 != nil {
                fmt.Println("New Trie Failed: ", err1)
                return
        }

        ret, _ := pyObj.SearchKeysByFirstLetter("t", md5)
        fmt.Printf("Search 't': %v\n", ret)
        ret, _ = pyObj.SearchKeysByFirstLetter("l", md5)
        fmt.Printf("Search 'l': %v\n", ret)

        ret, _ = pyObj.SearchKeys("te", md5)
        fmt.Printf("Search 'te': %v\n", ret)

        pyObj.DestroyTrie(md5)
}

func main() {
        var err error

        pyObj, err = search.NewSearch("com.deepin.api.Search",
                "/com/deepin/api/Search")
        if err != nil {
                fmt.Println("New Search Failed: ", err)
                return
        }

        testSearch()
}
